package net.xju.entity;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Announcement {
    private static final DateTimeFormatter DATE_TIME_FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    private Integer id;
    private String title;
    private String content;
    private LocalDateTime publishDate;  // 新增的publish_date字段
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    private Integer deleted;

    private String createTimeStr;
    private String updateTimeStr;

    public String getCreateTimeStr() {
        return createTime != null ? createTime.format(DATE_TIME_FORMATTER) : null;
    }

    public String getUpdateTimeStr() {
        return createTime != null ? updateTime.format(DATE_TIME_FORMATTER) : null;
    }

    public Announcement() {
    }

    public Announcement(Integer id, String title, String content, LocalDateTime createTime, LocalDateTime updateTime, Integer deleted) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.publishDate = publishDate;  // 新增的构造函数参数
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.deleted = deleted;
    }

    // 新增的getter和setter方法
    public LocalDateTime getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(LocalDateTime publishDate) {
        this.publishDate = publishDate;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getDeleted() {
        return deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    @Override
    public String toString() {
        return "Announcement{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", publishDate=" + publishDate +  // 新增的toString字段
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", deleted=" + deleted +
                '}';
    }
}